package leetcode;

import java.util.Arrays;

public class nineteen {
    public static int[] searchRange(int[] nums, int target) {
        if(nums==null||nums.length==0){
            return new int[]{-1,-1};
        }
        int begin=-1;
        int end=-1;
        int count=0;
        for(int i=0;i< nums.length;i++){
          if(nums[i]==target){
                if(count==0){
                    begin=i;
                    count++;
                    if(nums[i+1]!=target){
                        end=i;
                    }
                }else{
                    end=i;
                    count++;
                }

            }

        }
        return new int[]{begin,end};


    }

    public static void main(String[] args) {
//        nums = [5,7,7,8,8,10], target = 8
        int[] nums={5,7,7,8,8,10};
        int target=6;
        int[] ints = searchRange(nums, target);
        System.out.println(Arrays.toString(ints));

    }
}
